{{ define "main" }}
{{ $IsNav := eq .Params.type "nav"}}
{{ $IsSecrets := eq .Section "secrets"}}

<!-- 那些不需要文章相关功能（如目录层级，文章切换、字数时长统计等）的页面 -->
<!-- 正常博文 -->
{{ $IsPostPage := and (not $IsNav) }}

{{ $IS_DEV_ENV := eq .Site.BaseURL "http://localhost:1313/"}}


<div class="container-main container-page {{if $IsNav}}container-nav{{ end }}">

    {{ if and $IsNav }}
        <!-- 小型便捷外部搜索区域 -->
        {{ if .Site.Params.isShowMinishipBoxOfNav }}
		{{- partial "partials/_miniship.html" . -}}
        {{ end }}

        <!-- 搜索区域（仅作用于导航页） -->
        {{ if .Site.Params.isShowShipBoxOfNav }}
        <div class="ship">
            {{- partial "partials/_ship.html" . -}}
        </div>
        {{ end }}

        <!-- 最近文章 -->
        {{ if .Site.Params.isShowRecentPostsOfNav}}
        <div class="recentf">
            <span class="desc">- 最近更新 ➭</span>
            {{ range first 8 .Site.RegularPages.ByLastmod.Reverse }}
            <!-- {{.Type}} -->
            {{ if eq .Type "page" }}
            <div class="rec-post">
                <div class="rec-post-item">
                    <a href="{{.Permalink}}">{{ .Title }}</a>
                </div>
            </div>
            {{ end }}
            {{ end }}
        </div>
        {{ end }}
    {{ end }}

    <!-- 同一标签下的系列文章（按名称排序） -->
    {{ if .Site.Params.isShowRelativePosts }}
    {{ if .Params.tags }}
    <div class="rel">
        {{ $CurTag := index .Params.tags 0 }}
        <!-- {{ $CurTag }} -->
        {{ $CurTitle := .Title }}
        <!-- {{ $CurTitle }} -->
        {{ range .Site.Pages.ByTitle }}
        {{ if and (eq .Type "tags") (ne .Title "Tags") (ne .Title "Secrets")}}
        {{ if eq .Title $CurTag }}
        <div class="curtag-desc">
            <a href="{{.Permalink}}"><img src="/imgs/icons/tag.svg" width="16" /> 相关文章：{{ .Title }} <sup>{{len
                    .Pages}}</sup></a>
        </div>

        <div class="curtag-post">
            {{ range .Pages.ByTitle }}
            <!-- 适配 Obsidian 的 Templater 插件的 Front Matter -->
            {{if (ne .Title "<% tp.file.title %>")}}
                <div class="curtag-post-item {{ with eq $CurTitle .Title}}curtag-post-item--active{{ end }}">
                    <a href="{{.Permalink}}">{{ .Title }}</a>
                </div>
                {{ end }}
                {{ end }}
        </div>
        {{ end }}
        {{ end }}
        {{ end }}
    </div>
    {{ end }}
    {{ end }}

    <div class="desc">
        {{if $IsPostPage }}
        <span>
            <!-- 更新： -->
            <svg t="1656736000388" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
                p-id="7409" width="12" height="12">
                <path
                    d="M524.885333 338.986667L200.362667 663.466667c-17.28 15.274667-27.989333 36.693333-29.696 56.234666v133.76l130.730666 0.085334c22.784-1.621333 43.989333-12.245333 61.013334-31.701334l322.688-322.645333-160.213334-160.213333z m60.373334-60.330667l160.170666 160.213333 102.144-102.144a19.712 19.712 0 0 0 0-27.861333L715.093333 176.426667a19.456 19.456 0 0 0-27.605333 0L585.258667 278.613333zM701.312 85.333333c27.946667 0 54.741333 11.136 74.282667 30.848l132.309333 132.309334a105.045333 105.045333 0 0 1 0 148.565333L424.874667 879.957333c-29.824 34.346667-72.106667 55.466667-120.448 58.794667H85.333333v-42.666667l0.128-179.84c3.626667-44.970667 24.576-86.826667 56.448-114.944l485.12-485.034666A104.789333 104.789333 0 0 1 701.269333 85.333333z"
                    p-id="7410" fill="#adb5bd"></path>
            </svg>
            {{ .Date.Format "2006-01-02" }}&nbsp;&nbsp;&nbsp;
            <svg t="1656737270708" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
                p-id="23838" width="11" height="11">
                <path
                    d="M824.264 95.36c0-23.859 25.043-44.16 48.902-44.16s49.714 20.301 49.714 44.16v190.08c0 23.859-19.054 52.868-42.913 52.868h-190.08c-23.859 0-46.696-25.96-46.696-49.819s22.55-46.249 46.409-46.249h82.025C702.344 175.534 610.22 155.853 512 155.853c-206.775 0-360.398 149.372-360.398 356.147 0 206.775 153.623 358.23 360.398 358.23 206.775 0 357.467-151.455 357.467-358.23 0-23.859 23.634-50.706 53.413-50.706 29.78 0 49.92 26.847 49.92 50.706 0 254.493-206.307 460.8-460.8 460.8-254.493 0-460.8-206.307-460.8-460.8C51.2 257.507 257.507 51.2 512 51.2c122.4 0 226.684 33.296 312.264 117.369 0.358 0.351 0.358-24.052 0-73.209z"
                    p-id="23839" fill="#adb5bd"></path>
            </svg>
            {{ .Lastmod.Format "2006-01-02" }}&nbsp;&nbsp;&nbsp;
        </span>
        <span>
            <!-- 字数： -->
            <svg t="1656737548689" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
                p-id="33866" width="12" height="12">
                <path
                    d="M832.038608 64.662657H192.030028C121.255125 64.662657 63.940169 121.98845 63.940169 192.694717v446.793671C63.940169 710.205493 121.255125 767.643272 192.030028 767.643272h133.353183a63.940169 63.940169 0 0 1 55.219742 31.576328l76.099638 129.83828c12.358154 21.093031 33.790754 31.626903 55.216129 31.626903s42.832688-10.544709 55.198067-31.619678l76.222461-129.870792a63.940169 63.940169 0 0 1 55.212517-31.551041h133.54103c70.576219 0 127.732228-57.289669 127.732227-127.800865V192.391272C959.825022 121.85479 902.643727 64.662657 832.038608 64.662657zM895.884854 639.842407A63.85347 63.85347 0 0 1 832.092795 703.703103h-133.54103a127.753903 127.753903 0 0 0-110.349172 63.09847l-76.222461 129.856342a0.274545 0.274545 0 0 1 0-0.050574h-0.032512s-0.021675 0.061411-0.032512 0.061412l-76.1466-129.85273A127.804477 127.804477 0 0 0 325.383211 703.703103H192.030028A64.207489 64.207489 0 0 1 127.880338 639.488388V192.694717A64.102729 64.102729 0 0 1 192.030028 128.602826h640.00858A63.799284 63.799284 0 0 1 895.884854 192.391272v447.451135z"
                    fill="#adb5bd" p-id="33867"></path>
                <path
                    d="M608.154093 288.092004A31.970084 31.970084 0 0 0 576.184009 320.062089v160.078006l-134.650049-179.278119A31.970084 31.970084 0 0 0 384.002258 320.062089v255.760676a31.970084 31.970084 0 0 0 63.940169 0v-159.958796l134.650048 179.274507a31.970084 31.970084 0 0 0 57.531703-19.200113V320.062089a31.970084 31.970084 0 0 0-31.970085-31.970085z"
                    fill="#adb5bd" p-id="33868"></path>
            </svg>
            {{ .WordCount }} 字</span>&nbsp;
        <span>
            <!-- 阅读： -->
            <svg t="1656737462334" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
                p-id="32892" width="12" height="12">
                <path
                    d="M512 74.666667C270.933333 74.666667 74.666667 270.933333 74.666667 512S270.933333 949.333333 512 949.333333 949.333333 753.066667 949.333333 512 753.066667 74.666667 512 74.666667z m0 810.666666c-204.8 0-373.333333-168.533333-373.333333-373.333333S307.2 138.666667 512 138.666667 885.333333 307.2 885.333333 512 716.8 885.333333 512 885.333333z"
                    p-id="32893" fill="#adb5bd"></path>
                <path
                    d="M695.466667 567.466667l-151.466667-70.4V277.333333c0-17.066667-14.933333-32-32-32s-32 14.933333-32 32v238.933334c0 12.8 6.4 23.466667 19.2 29.866666l170.666667 81.066667c4.266667 2.133333 8.533333 2.133333 12.8 2.133333 12.8 0 23.466667-6.4 29.866666-19.2 6.4-14.933333 0-34.133333-17.066666-42.666666z"
                    p-id="32894" fill="#adb5bd"></path>
            </svg>
            {{ .ReadingTime }} 分钟</span>
        {{ if not $IsSecrets}}
        {{- partial "partials/_ctgtag.html" . -}}
        {{ end }}
        {{ end }}
    </div>

    <div class="toc">
        {{ if and .IsPage (not $IsSecrets) }}
        {{- partial "partials/_page-operation.html" . -}}
        {{end}}
        {{ $.TableOfContents }}
    </div>

    <div class='content {{with $IsNav}}content-nav{{end}} {{with .Params.card}}content-card{{ end }}'>
        {{ .Content }}
    </div>

    {{ if and .IsPage $IsPostPage (not $IsSecrets) .Site.Params.utterances.active (not $IS_DEV_ENV) }}
    {{- partial "partials/_comment.html" . -}}
    {{ end }}

    {{ if and .IsPage $IsPostPage (not $IsSecrets) .Site.Params.giscus.active (not $IS_DEV_ENV) }}
    {{- partial "partials/_comment-giscus.html" . -}}
    {{ end }}
</div>
{{ end }}